package com.xca.znb.presenter;

import com.xca.znb.contact.GoodsManagerContact;
import com.xca.znb.entity.Goods;
import com.xca.znb.model.imodel.IGoodsManager;

public class GoodsManagerPresenter {
    private GoodsManagerContact contact ;
    private IGoodsManager iGoodsManager ;
    public GoodsManagerPresenter(GoodsManagerContact contact , IGoodsManager iGoodsManager){
        this.contact = contact ;
        this.iGoodsManager = iGoodsManager ;
    }
    public void showGoodsMessage(int id){
        Goods goods = iGoodsManager.getGoodsById(id);
        String firstImg = goods.getFirst_image();
        double price = goods.getPrice();
        String unit = goods.getUnit();
        String state = goods.getState();
        String name = goods.getName() ;
        String local = goods.getAddress();
        String freight = goods.getFreight();
        String text = goods.getText();
        String imgList = goods.getImg_list();
        contact.showGoodsMessage(firstImg,price,unit,name,local,freight,text,imgList,state);
    }
    public Goods getGoodsById(int id){
        return iGoodsManager.getGoodsById(id);
    }
    public void updateGoodsByIdAndState(int id , String state){
        iGoodsManager.updateGoodsByIdAndState(id, state);
    }
    public void deleteGoodsById(int id){
        iGoodsManager.deleteGoodsById(id);
    }
}
